import request from '@/utils/request'

const url = 'http://192.168.10.100:9881/rabc'

export function getAsyncRouterRoles() {
  return request({
    url: url + '/role/getAsyncRouterRoles',
    method: 'get'
  })
}

export function fetchPageRolesByPageName(pageName) {
  console.log('fetch roles')
  return request({
    url: url + '/role/getUserPageRoles',
    method: 'get',
    params: { 'pageName': pageName }
  })
}

export function getRoutes() {
  return request({
    url: '/vue-element-admin/routes',
    method: 'get'
  })
}

export function getRoles() {
  return request({
    url: '/vue-element-admin/roles',
    method: 'get'
  })
}

export function addRole(data) {
  return request({
    url: url + '/role/addRole',
    method: 'post',
    data
  })
}

export function updateRole(id, data) {
  return request({
    url: `/vue-element-admin/role/${id}`,
    method: 'put',
    data
  })
}

export function deleteRole(data) {
  return request({
    url: url + '/role/deleteRole',
    method: 'delete',
    params: data
  })
}
